﻿CREATE TABLE [dbo].[Articulos] (
    [IdArticulo]                  INT             IDENTITY (1, 1) NOT NULL,
    [IdTipoArticulo]              TINYINT         NOT NULL,
    [IdSubRubroArticulo]          INT             NOT NULL,
    [IdMarca]                     INT             NOT NULL,
    [IdDescuentoRecargoCantidad]  INT             NOT NULL,
    [IdTipoComisionArticulo]      TINYINT         NOT NULL,
    [IdTipoImpuestoArticulo]      TINYINT         NOT NULL,
    [IdTipoCostoArticulo]         TINYINT         NOT NULL,
    [IdDescuentoRecargoFechaHora] INT             NOT NULL,
    [Codigo]                      VARCHAR (20)    NOT NULL,
    [Nombre]                      VARCHAR (50)    NOT NULL,
    [ExistenciaMinima]            INT             NOT NULL,
    [ExistenciaMaxima]            INT             NOT NULL,
    [Costo]                       DECIMAL (19, 4) NOT NULL,
    [Comision]                    DECIMAL (19, 4) NOT NULL,
    [ComisionMaxima]              DECIMAL (19, 4) NOT NULL,
    [Iva]                         DECIMAL (19, 4) NOT NULL,
    [Impuesto]                    DECIMAL (19, 4) NOT NULL,
    [Observaciones]               VARCHAR (500)   NOT NULL,
    [Imagen]                      IMAGE           NULL,
    [EstaEliminado]               BIT             CONSTRAINT [DF_Articulos_EstaEliminado] DEFAULT ((0)) NOT NULL,
    [CodigoBarras]                VARCHAR (20)    NOT NULL,
    CONSTRAINT [PK_Articulos] PRIMARY KEY CLUSTERED ([IdArticulo] ASC),
    CONSTRAINT [FK_Articulos_DescuentosRecargosCantidades] FOREIGN KEY ([IdDescuentoRecargoCantidad]) REFERENCES [dbo].[DescuentosRecargosCantidades] ([IdDescuentoRecargoCantidad]),
    CONSTRAINT [FK_Articulos_DescuentosRecargosFechasHoras] FOREIGN KEY ([IdDescuentoRecargoFechaHora]) REFERENCES [dbo].[DescuentosRecargosFechasHoras] ([IdDescuentoRecargoFechaHora]),
    CONSTRAINT [FK_Articulos_Marcas] FOREIGN KEY ([IdMarca]) REFERENCES [dbo].[Marcas] ([IdMarca]),
    CONSTRAINT [FK_Articulos_SubRubrosArticulos] FOREIGN KEY ([IdSubRubroArticulo]) REFERENCES [dbo].[SubRubrosArticulos] ([IdSubRubroArticulo]),
    CONSTRAINT [FK_Articulos_TiposArticulos] FOREIGN KEY ([IdTipoArticulo]) REFERENCES [dbo].[TiposArticulos] ([IdTipoArticulo]),
    CONSTRAINT [FK_Articulos_TiposComisionesArticulos] FOREIGN KEY ([IdTipoComisionArticulo]) REFERENCES [dbo].[TiposComisionesArticulos] ([IdTipoComisionArticulo]),
    CONSTRAINT [FK_Articulos_TiposCostosArticulos] FOREIGN KEY ([IdTipoCostoArticulo]) REFERENCES [dbo].[TiposCostosArticulos] ([IdTipoCostoArticulo]),
    CONSTRAINT [FK_Articulos_TiposImpuestosArticulos] FOREIGN KEY ([IdTipoImpuestoArticulo]) REFERENCES [dbo].[TiposImpuestosArticulos] ([IdTipoImpuestoArticulo])
);













